// 添加订阅
export function addSubscription(subscriptions, callback) {
    subscriptions.push(callback);
    // 移除相同订阅(除重操作)
    const removeSAubscription = () => {
        const idx = subscriptions.indexOf(callback);
        if (idx > -1) {
            subscriptions.splice(idx, 1);
        }
    };
    return removeSAubscription;
}

// 发布事件
export function triggerSubscriptions(subscriptions, ...args) {
    subscriptions.slice().forEach((cb) => cb(...args));
}
